package com.htic.suricata.spreadsheet.model;

import org.apache.poi.ss.usermodel.Workbook;

import com.htic.suricata.core.model.TestModulePopulationAlgorithm;
import com.htic.suricata.core.model.TestSource;
import com.htic.suricata.core.model.TestSourceParameters;
import com.htic.suricata.spreadsheet.dao.impl.TestModuleSpreadSheetDAO;
import com.htic.suricata.spreadsheet.dao.impl.TestSourceSpreadSheetDAO;
import com.htic.suricata.spreadsheet.dao.impl.TestSuiteSpreadSheetDAO;

public class TestSourceSpreadSheet extends TestSource {

	private Workbook workbook;
	private SpreadSheetTemplate spreadSheetTemplate;
	private TestModulePopulationAlgorithm testModulePopulationAlgorithm;


	public TestSourceSpreadSheet(TestSourceParameters testSourceParameters) {
		super(testSourceParameters);

		TestSourceSpreadSheetDAO testSourceSpreadSheetDAO	= new TestSourceSpreadSheetDAO ();
		try {
			setWorkbook(testSourceSpreadSheetDAO.populateWorkbook((TestSourceSpreadSheetParameters)testSourceParameters));
			setSpreadSheetTemplate(testSourceSpreadSheetDAO.populateSpreadSheetTemplate(workbook));
			setTestModulePopulationAlgorithm(testSourceSpreadSheetDAO.populateTestModulePopulationAlgorithm(workbook));
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException();
		}
	}


	@Override
	protected void inyectDependencies() {
		setTestModuleDAO(new TestModuleSpreadSheetDAO());
		setTestSuiteDAO(new TestSuiteSpreadSheetDAO());
	}


	//Getters && Setters
	public Workbook getWorkbook() {
		return workbook;
	}
	public void setWorkbook(Workbook workbook) {
		this.workbook = workbook;
	}
	public SpreadSheetTemplate getSpreadSheetTemplate() {
		return spreadSheetTemplate;
	}
	public void setSpreadSheetTemplate(SpreadSheetTemplate spreadSheetTemplate) {
		this.spreadSheetTemplate = spreadSheetTemplate;
	}
	public TestModulePopulationAlgorithm getTestModulePopulationAlgorithm() {
		return testModulePopulationAlgorithm;
	}
	public void setTestModulePopulationAlgorithm(TestModulePopulationAlgorithm testModulePopulationAlgorithm) {
		this.testModulePopulationAlgorithm = testModulePopulationAlgorithm;
	}
}